package com.hualan.sfzy.service.impl.consult;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hualan.sfzy.constant.CommonConstant;
import com.hualan.sfzy.mapper.consult.ConsultExpertiseMapper;
import com.hualan.sfzy.model.entity.Consult;
import com.hualan.sfzy.model.entity.ConsultExpertise;
import com.hualan.sfzy.model.vo.ConsultExpertiseVO;
import com.hualan.sfzy.service.BaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class ConsultExpertiseServiceImpl implements BaseService<ConsultExpertise> {
    @Autowired
    private ConsultExpertiseMapper mapper;

    @Override
    public int add(ConsultExpertise entity) {
        return mapper.insert(entity);
    }
    // 批量添加咨询师擅长领域表中间表
    public int addPro(List<ConsultExpertise> list){
        return mapper.insertPro(list);
    }

    @Override
    public int edit(ConsultExpertise entity) {
        return mapper.update(entity);
    }

    @Override
    public int remove(Integer id) {
        return mapper.delete(id);
    }

    @Override
    public int removeBatch(Integer[] ids) {
        return mapper.deleteBatch(ids);
    }

    @Override
    public List<ConsultExpertise> find() {
        return mapper.select(null);
    }



    @Override
    public Map<String, Object> findPage(Integer pageNum, Integer pageSize, ConsultExpertise entity) {
        PageHelper.startPage(pageNum, pageSize);
        List<ConsultExpertise> list = mapper.select(entity);
        PageInfo<ConsultExpertise> info = new PageInfo<>(list);
        Map<String, Object> map = new HashMap<>();
        map.put(CommonConstant.PAGE_LIST, list);
        map.put(CommonConstant.PAGE_TOTAL, info.getPages());
        map.put(CommonConstant.TOTAL, info.getTotal());
        return map;
    }

    @Override
    public ConsultExpertise findById(Integer id) {
        return mapper.selectById(id);
    }

    // 根据咨询师id查询咨询师擅长领域表中间表
    public List<Map<Integer,Object>> selectConsultExpert() {
        return mapper.selectConsultExpert();
    }
    // 根据咨询师id查询咨询师擅长领域表中间表
    public Map<Integer,Object> selectConsultExpertId(Integer id) {
        return mapper.selectConsultExpertId(id);
    }

}
